package com.rowger.player.util

import com.rowger.player.R
import com.rowger.player.base.BaseFragment
import com.rowger.player.ui.fragment.HomeFragment
import com.rowger.player.ui.fragment.MvFragment
import com.rowger.player.ui.fragment.VBangFragment
import com.rowger.player.ui.fragment.YueDanFragment

/**
 * Created by Administrator on 2018/5/10.
 * 管理fragment的util类
 */
class FragmentUtil private constructor(){//私有化构造方法
    val homeFragment by lazy { HomeFragment() }
    val mvFragment by lazy { MvFragment() }
    val vbangFragment by lazy { VBangFragment() }
    val yuedanFragment by lazy { YueDanFragment() }

    companion object {
        val fragmentUtil by lazy { FragmentUtil() }
    }
    fun getFragment(tabId:Int):BaseFragment?{
        println("tabid------------------$tabId")
      when(tabId){
          R.id.tab_home->return homeFragment
          R.id.tab_mv->return mvFragment
          R.id.tab_vban->return vbangFragment
          R.id.tab_yuedan->return yuedanFragment
      }
       //getFragment接受id，返回BaseFragment，因为BaseFragment默认不接受null。所以给一个问号
       return null
    }
}